package com.hongxun.design.bean;

import android.text.Editable;
import android.text.TextWatcher;

import java.util.ArrayList;

import com.hongxun.design.bean.photopassbean.SystemTypeBean;
import com.hongxun.design.constant.Constant;
import com.hongxun.design.utils.soundUtil.UPlayer;

/**
 * Created by zerdoor_pc on 2016/5/13.
 * 环境拍照-详情
 */
public class PhotoEnvironmentalItemBean {
    private String title;
    private String titlecode;
    private int type;
    private String value;
    private String valuecode;
    private String hintValue;
    private ArrayList<String> data;
    private ArrayList<String> dataValue;
    private String path;//语音path
    private TextWatcher textWatcher;
    private boolean ismust;
    int inputType;
    public TextWatcher getTextWatcher() {
        return textWatcher;
    }

    public void setTextWatcher() {
        textWatcher = new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

            }

            @Override
            public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {

            }

            @Override
            public void afterTextChanged(Editable editable) {
                value = editable.toString();
                valuecode = editable.toString();
            }
        };
    }

    public PhotoEnvironmentalItemBean(int inputType,boolean ismust,String title, String titlecode, int type, String value, String hintValue, ArrayList<SystemTypeBean> list, String path) {
        this.title = title;
        this.titlecode = titlecode;
        this.type = type;
        this.value = value;
        this.hintValue = hintValue;
        this.inputType = inputType;
        this.ismust = ismust;
        this.path = path;
        if (list != null && list.size() > 0) {
            this.data = new ArrayList<>();
            this.dataValue = new ArrayList<>();
            for (SystemTypeBean bean : list) {
                if (value != null && bean.getTypename().equals(value)) {
                    valuecode = bean.getTypecode();
                }
                data.add(bean.getTypename());
                dataValue.add(bean.getTypecode());
            }
        }
        if (type == Constant.remarksItem || type == Constant.EdItem) {
            setTextWatcher();
        }
        if ((value==null||value.length()==0)&&path!=null&&path.length()>0){
            this.value=((double) UPlayer.getIntence(path).getDuration()/ (double)1000)+"";
        }
    }

    public int getInputType() {
        return inputType;
    }

    public void setInputType(int inputType) {
        this.inputType = inputType;
    }

    public boolean ismust() {
        return ismust;
    }

    public void setIsmust(boolean ismust) {
        this.ismust = ismust;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public String getHintValue() {
        return hintValue;
    }

    public void setHintValue(String hintValue) {
        this.hintValue = hintValue;
    }

    public ArrayList<String> getData() {
        return data;
    }

    public void setData(ArrayList<String> data) {
        this.data = data;
    }

    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    public String getTitlecode() {
        return titlecode;
    }

    public void setTitlecode(String titlecode) {
        this.titlecode = titlecode;
    }


    public ArrayList<String> getDataValue() {
        return dataValue;
    }

    public void setDataValue(ArrayList<String> dataValue) {
        this.dataValue = dataValue;
    }

    public String getValuecode() {
        return valuecode;
    }

    public void setValuecode(String valuecode) {
        this.valuecode = valuecode;
    }
}
